#include "stdafx.h"
#include "../include/UMyGrid9.h"
#include <math.h>

#ifdef _DEBUG
	#undef THIS_FILE
	static char THIS_FILE[] = __FILE__;
	#define new DEBUG_NEW
#endif

///////////////////////////////////////////////////////////////////////////////////////////////////
int UMyGrid9_SortByString(LPVOID lpValue1,LPVOID lpValue2)
{
	return lstrcmpi((LPCTSTR)lpValue1,(LPCTSTR)lpValue2);
}

int UMyGrid9_SortByDouble(LPVOID lpValue1,LPVOID lpValue2)
{
	if(fabs(*(double*)lpValue1-*(double*)lpValue2)<0.000001) return(0);
	return(*(double*)lpValue1>*(double*)lpValue2?1:-1);
}

int UMyGrid9_SortByLong(LPVOID lpValue1,LPVOID lpValue2)
{
	if(*(long*)lpValue1==*(long*)lpValue2) return(0);
	return(*(long*)lpValue1>*(long*)lpValue2?1:-1);
}

int UMyGrid9_SortByInt64(LPVOID lpValue1,LPVOID lpValue2)
{
	if(*(__int64*)lpValue1==*(__int64*)lpValue2) return(0);
	return(*(__int64*)lpValue1>*(__int64*)lpValue2?1:-1);
}

int UMyGrid9_ChooseSimple(LPVOID lpValue)
{
	pgrid_data_index9 pRow=(pgrid_data_index9)lpValue;
	if (!pRow) return 0;

	if (_tcsstr(pRow->szData,_T("01"))!=NULL || _tcsstr(pRow->szData,_T("03"))!=NULL)
		return 1;
	else
		return 0;
}

int UMyGrid9_ChooseSimple2(LPVOID lpValue)
{
	pgrid_data_index9 pRow=(pgrid_data_index9)lpValue;
	if (!pRow) return 0;

	if (_tcsstr(pRow->szData,_T("02"))!=NULL || _tcsstr(pRow->szData,_T("05"))!=NULL)
		return 1;
	else
		return 0;
}
